<cfcomponent displayname="CrafterListCollection" extends="crafter.CrafterDocumentCollection" output="no" accessors="yes">
	
	
	<!--- init() --->
	<cffunction name="init" access="public" returntype="any" output="no">
		<cfargument name="crafterFactory" type="any" required="yes" />
		<cfargument name="collectionName" type="string" required="no" default="" />
		<cfscript>
			super.init(
				crafterFactory = arguments.crafterFactory,
				collectionName = arguments.collectionName		   
			);
			return this;
		</cfscript>
	</cffunction>
	
	
	<!--- load() --->
	<cffunction name="load" access="public" returntype="any" hint="" output="no">
		<cfargument name="path" type="string" required="false" default="" />
		<cfargument name="doc" type="crafter.CrafterDocument" required="false" />
		<cfscript>
			if (arguments.path NEQ "") {
				loadByPath(path = arguments.path);
			}
			else if (IsInstanceOf(arguments.doc,"crafter.CrafterDocument")) {
				loadByDocument(doc = arguments.doc);
			}
		</cfscript>		
	</cffunction>
	
	
	<!--- loadByPath() --->
	<cffunction name="loadByPath" access="public" returntype="any" hint="" output="no">
		<cfargument name="path" type="string" required="true" />
		<cfscript>
			local.oDoc = getCrafterFactory().getDocument(path = arguments.path);
			loadByDocument(doc = local.oDoc);
		</cfscript>
	</cffunction>
	
	
	<!--- loadByDocument() --->
	<cffunction name="loadByDocument" access="public" returntype="any" hint="" output="no">
		<cfargument name="doc" type="crafter.CrafterDocument" required="true" />
		<cfscript>
			// Pull out the items from the XML
			local.arItems = XmlSearch(arguments.doc.getXml(),'//item');
			
			// See if there any items were found. If so, loop over them.
			if (NOT ArrayIsEmpty(local.arItems)) {
				for (var i=1; i LTE ArrayLen(local.arItems); i++) {
					addToCollection(item = local.arItems[i].XmlText);
				}
			}
		</cfscript>
	</cffunction>

	
</cfcomponent>